package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ChatConfig;
import com.ruoyi.system.service.IChatConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 聊天系统配置Controller
 * 
 * @author ruoyi
 * @date 2025-08-30
 */
@RestController
@RequestMapping("/system/chatConfig")
public class ChatConfigController extends BaseController
{
    @Autowired
    private IChatConfigService chatConfigService;

    /**
     * 查询聊天系统配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:chatConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChatConfig chatConfig)
    {
        startPage();
        List<ChatConfig> list = chatConfigService.selectChatConfigList(chatConfig);
        return getDataTable(list);
    }

    /**
     * 导出聊天系统配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:chatConfig:export')")
    @Log(title = "聊天系统配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChatConfig chatConfig)
    {
        List<ChatConfig> list = chatConfigService.selectChatConfigList(chatConfig);
        ExcelUtil<ChatConfig> util = new ExcelUtil<ChatConfig>(ChatConfig.class);
        util.exportExcel(response, list, "聊天系统配置数据");
    }

    /**
     * 获取聊天系统配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:chatConfig:query')")
    @GetMapping(value = "/{configId}")
    public AjaxResult getInfo(@PathVariable("configId") Integer configId)
    {
        return success(chatConfigService.selectChatConfigByConfigId(configId));
    }

    /**
     * 新增聊天系统配置
     */
    @PreAuthorize("@ss.hasPermi('system:chatConfig:add')")
    @Log(title = "聊天系统配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChatConfig chatConfig)
    {
        return toAjax(chatConfigService.insertChatConfig(chatConfig));
    }

    /**
     * 修改聊天系统配置
     */
    @PreAuthorize("@ss.hasPermi('system:chatConfig:edit')")
    @Log(title = "聊天系统配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChatConfig chatConfig)
    {
        return toAjax(chatConfigService.updateChatConfig(chatConfig));
    }

    /**
     * 删除聊天系统配置
     */
    @PreAuthorize("@ss.hasPermi('system:chatConfig:remove')")
    @Log(title = "聊天系统配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{configIds}")
    public AjaxResult remove(@PathVariable Integer[] configIds)
    {
        return toAjax(chatConfigService.deleteChatConfigByConfigIds(configIds));
    }
}
